﻿/* PN264 - A Parallel H.264 Encoding Utility
 * Copyright © 2009 PN264 Development Team
 *
 * This software is released the terms and conditions of the MIT License,
 * a copy of which can be found in the License.txt file.
 *
 * Contributors:
 * Will 'AnarkiNet' Shelley (AnarkiNet@gmail.com)
 */
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Net;

namespace PN264
{
    /// <summary>
    /// Represents a job, which is a collection of <see cref="Task"/>s that
    /// are completed in order to yield a result from an input.
    /// </summary>
    public class Job
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="Job"/> class.
        /// </summary>
        /// <param name="id"></param>
        public Job(long id)
        {
            this.id = id;
        }

        #endregion
        #region Fields

        private long id;
        private string group;
        private string name;
        private string inputPath;
        private string outputPath;
        private JobStatus stage;
        private DateTime created;
        private DateTime started;
        private DateTime ended;
        private IPEndPoint owner;
        private bool isLocal;

        #endregion
        #region Properties

        /// <summary>
        /// Gets or sets the name of the group that the current
        /// <see cref="Job"/> belongs to.
        /// </summary>
        /// <remarks>
        /// Jobs in a group must be executed sequentially, so if one job
        /// depends on the output of another job (for example, a multi-pass
        /// encode), the jobs would be grouped so that the second pass job
        /// would only begin after the first had finished. Jobs with no group
        /// are executed as fast as possible.
        /// </remarks>
        public string Group
        {
            get
            {
                return this.group;
            }
            set
            {
                this.group = value;
            }
        }

        /// <summary>
        /// Gets the numeric identifier of the current <see cref="Job"/>.
        /// </summary>
        public long Id
        {
            get
            {
                return this.id;
            }
            set
            {
                id = value;
            }
        }

        /// <summary>
        /// Gets or sets the human-readable name of the current
        /// <see cref="Job"/>.
        /// </summary>
        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                this.name = value;
            }
        }

        /// <summary>
        /// Gets or sets the path of the input file or contentBuffer.
        /// </summary>
        public string InputPath
        {
            get
            {
                return this.inputPath;
            }
            set
            {
                this.inputPath = value;
            }
        }

        /// <summary>
        /// Gets or sets a value that indicates if the current
        /// <see cref="Job"/> is a local job (owned by the local machine).
        /// </summary>
        public bool IsLocal
        {
            get
            {
                return this.isLocal;
            }
            set
            {
                this.isLocal = value;
            }
        }

        /// <summary>
        /// Gets or sets the path of the output file or contentBuffer.
        /// </summary>
        public string OutputPath
        {
            get
            {
                return this.outputPath;
            }
            set
            {
                this.outputPath = value;
            }
        }

        /// <summary>
        /// Gets the <see cref="IPEndPoint"/> of the owner of the current
        /// <see cref="Job"/>.
        /// </summary>
        public IPEndPoint Owner
        {
            get
            {
                return this.owner;
            }
            set
            {
                this.owner = value;
            }
        }

        /// <summary>
        /// Gets or sets the <see cref="JobStatus"/> of the current
        /// <see cref="Job"/>.
        /// </summary>
        public JobStatus Status
        {
            get
            {
                return this.stage;
            }
            set
            {
                this.stage = value;
            }
        }

        /// <summary>
        /// Gets or sets the <see cref="DateTime"/> that represents when the
        /// current <see cref="Job"/> was first created.
        /// </summary>
        public DateTime Created
        {
            get
            {
                return this.created;
            }
            set
            {
                this.created = value;
            }
        }

        /// <summary>
        /// Gets or sets the <see cref="DateTime"/> that represents when the
        /// current <see cref="Job"/> was started.
        /// </summary>
        public DateTime Started
        {
            get
            {
                return this.started;
            }
            set
            {
                this.started = value;
            }
        }

        /// <summary>
        /// Gets or sets the <see cref="DateTime"/> that represents when the
        /// current <see cref="Job"/> was ended.
        /// </summary>
        public DateTime Ended
        {
            get
            {
                return this.ended;
            }
            set
            {
                this.ended = value;
            }
        }
        #endregion
    }
}
